#include "container.hpp"
#include <assert.h>

Container::Container(unsigned short capacity, unsigned short content = 0):
	m_capacity(capacity), m_content(content)
{
	assert(m_capacity>=m_content && m_content>=0&&"Контейнер сломался");
}
void Container::setContent(int value)
{
	if(value>m_capacity)
	{
		m_content = m_capacity;
	}
	else if (value<0)
	{
		m_content = 0;
	}
	
}
int Container::getCapacity() const
{
	return m_capacity;
}
const int& Container::getContent() const
{
	return m_content;
}
bool Container::isEmpty() const
{
	return m_content<=0;
}

int Container::take(unsigned short value)
{
	if(m_content>=value)
	{
		m_content-=value;
		return value;
	}
	return 0;
}
void Container::add(unsigned short value)
{
	m_content += value;
	if(m_content > m_capacity)
	{
		m_content = m_capacity;
	}
}